package cj.web.prize.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.prize.domain.PrizeGift;

/**
 * 
 * @author 
 *
 */
@DAO
public interface PrizeGiftDAO{
	@SQL("SELECT * FROM PrizeGift #if(:t.remark!=''){WHERE remark like '%##(:t.remark)%' } ORDER BY order_no LIMIT :t.start,:t.length ")
    List<PrizeGift> query(@SQLParam("t") PrizeGift prizeGift);
	
	@SQL("SELECT count(*) FROM PrizeGift #if(:t.remark!=''){WHERE remark like '%##(:t.remark)%' } ")
    int querySize(@SQLParam("t") PrizeGift prizeGift);
	
    @SQL("select * from PrizeGift where id=:1")
    PrizeGift queryById(int id);
    
	@SQL("UPDATE PrizeGift SET active_id=:t.activeId,name=:t.name,count=:t.count,probability=:t.probability,remark=:t.remark,order_no=:t.orderNo,day_count=:t.dayCount WHERE id=:t.id")
    void update(@SQLParam("t") PrizeGift prizeGift);
    
    @SQL("update PrizeGift set count = count -1 where active_id=:1 and name=:2 ")
    void deleteById(String id);
    
    //----------以下两个SQL语句在判断概率的时候 用到误删除
    @SQL("select * from PrizeGift where active_id=:1 order by order_no ")
    List<PrizeGift> queryByActiveId(int activeId);
    
    @SQL("update PrizeGift set count = count -1 where active_id=:1 and name=:2 ")
	void updateCountByActiveId(int activeId,String name);
}